Skip to content

Conversation

@andreidan
Copy link
Contributor

This attempts to fix a flay test where the term_freq returned by the multiple terms vectors API was null.
I was not able to reproduce this test but this proposes a fix based on the following running theory:

  • an Elasticsearch cluster comprised of at least 2 nodes
  • we create a couple of indices with 1 primary and 1 replica
  • we index a document that was acknowledged only by the primary (because wait_for_active_shards defaults to 1)
  • the test executes the multiple terms vectors API and it hits the node hosting the replica shard, which hasn't yet received the document we ingested in the primary shard.

This race condition between the document replication and the test running the terms vectors API on the replica shard could yield a null value for the the term's term_freq (as the replica shard contains 0 documents).

This PR proposes we change the wait_for_active_shards value to all so each write is acknowledged by all replicas before the client receives the response.

(cherry picked from commit a148fa2)
Signed-off-by: Andrei Dan [email protected]

Backport of #121442

This attempts to fix a flay test where the term_freq returned
by the multiple terms vectors API was `null`.
I was not able to reproduce this test but this proposes a fix
based on the following running theory:
- an Elasticsearch cluster comprised of at least 2 nodes
- we create a couple of indices with 1 primary and 1 replica
- we index a document that was acknowledged only by the primary
(because `wait_for_active_shards` defaults to `1`)
- the test executes the multiple terms vectors API and it hits the
node hosting the replica shard, which hasn't yet received the
document we ingested in the primary shard.

This race condition between the document replication and the test
running the terms vectors API on the replica shard could yield
a `null` value for the the term's `term_freq` (as the replica shard
contains 0 documents).

This PR proposes we change the `wait_for_active_shards` value to
`all` so each write is acknowledged by all replicas before the client
receives the response.

(cherry picked from commit a148fa2)
Signed-off-by: Andrei Dan <[email protected]>
@andreidan andreidan added >test Issues or PRs that are addressing/adding tests backport :Search Foundations/Search Catch all for Search Foundations labels Feb 10, 2025
@andreidan andreidan added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Feb 10, 2025
@elasticsearchmachine elasticsearchmachine merged commit 8854117 into elastic:9.0 Feb 10, 2025
16 checks passed
@andreidan andreidan deleted the backport/9-0-fix-test-mtermvectors branch February 10, 2025 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) backport :Search Foundations/Search Catch all for Search Foundations >test Issues or PRs that are addressing/adding tests v9.0.1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants